import { Contact, Response } from './types';
import axios from '../utils/axios';

// 获取联系人列表
export async function getContacts(): Promise<Response<Contact[]>> {
  return axios.get('/contacts');
}

// 获取单个联系人
export async function getContact(id: string): Promise<Response<Contact>> {
  return axios.get(`/contacts/${id}`);
}

// 创建联系人
export async function createContact(contact: Omit<Contact, 'id'>): Promise<Response<Contact>> {
  return axios.post('/contacts', contact);
}

// 更新联系人
export async function updateContact(id: string, contact: Partial<Contact>): Promise<Response<Contact>> {
  return axios.put(`/contacts/${id}`, contact);
}

// 删除联系人
export async function deleteContact(id: string): Promise<Response<null>> {
  return axios.delete(`/contacts/${id}`);
}

// 设置默认联系人
export async function setDefaultContact(id: string): Promise<Response<Contact>> {
  return axios.put(`/contacts/${id}/default`, {});
} 